home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / gfx / 3d / povray_wb3beta.lzh / source.lzh / modeid.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  2.9 KB  |  138 lines

  1. /*
  2. **    This routines were only modified by me. 
  3. **  I forgot the name of the author, but it was public domain.
  4. */
  5.  
  6. #include <exec/types.h>
  7. #include <proto/graphics.h>
  8. #include <proto/intuition.h>
  9. #include <graphics/modeid.h>
  10. #include <graphics/display.h>
  11. #include <graphics/displayinfo.h>
  12. #include <proto/asl.h>
  13.  
  14. #include <stdlib.h>
  15. #include <stdio.h>
  16.  
  17. extern struct Library ASLBase;
  18.  
  19. #define MAX_HEIGHT 20000
  20. #define MAX_WIDTH  20000
  21. ULONG MIN_DEPTH;
  22. #define MAX_DEPTH     32
  23. BOOL DD;    
  24.  
  25. int DEFAULT_WIDTH, DEFAULT_HEIGHT, MINIMUM_WIDTH, MINIMUM_HEIGHT;
  26.  
  27. __asm __saveds BOOL ScreenModeHook(register __a1 ULONG modeid)
  28. {
  29. /*
  30. **    try to filter EHB out, but does not work.
  31. */
  32.     struct DisplayInfo   disinfo;
  33.  
  34.     if(DD == FALSE)
  35.     {
  36.         if(GetDisplayInfoData(NULL,(UBYTE*)&disinfo,sizeof(struct DisplayInfo),DTAG_DIMS,modeid) >= sizeof(struct DisplayInfo))
  37.         {
  38.             if((disinfo.PropertyFlags && DIPF_IS_EXTRAHALFBRITE) && 
  39.               (disinfo.PropertyFlags && DIPF_IS_HAM)) return FALSE;    
  40.         }
  41.         else 
  42.         {
  43.             return TRUE;
  44.         }
  45.     }
  46.     else
  47.     {
  48.         return TRUE;
  49.     }
  50. }
  51.  
  52. int GetScreenMode (ULONG *modeID, int *height, int *width  , int *autoscroll,
  53.                 int *depth,int M_W, int M_H, ULONG pfl)
  54. {
  55.     int
  56.         rslt,
  57.         mode_width  = *width ,
  58.         mode_height = *height ;
  59.     struct Hook
  60.         ScreenReqHook;
  61.     struct ScreenModeRequester
  62.         *screenReq;
  63.     
  64.     MINIMUM_WIDTH  = M_W;
  65.     DEFAULT_WIDTH  = M_W;
  66.     MINIMUM_HEIGHT = M_H;
  67.     DEFAULT_HEIGHT = M_H;
  68.  
  69.     if(*depth < 0)
  70.     {
  71.         DD = FALSE; 
  72.         MIN_DEPTH = -1*(*depth);
  73.     }
  74.     else 
  75.     {
  76.         DD = TRUE;
  77.         MIN_DEPTH = (*depth);
  78.     }
  79.  
  80.     ScreenReqHook.h_Data     = NULL;
  81.     ScreenReqHook.h_Entry    = (ULONG (*)()) ScreenModeHook;
  82.     ScreenReqHook.h_SubEntry = NULL;
  83.  
  84.     screenReq = (struct ScreenModeRequester *) AllocAslRequestTags (ASL_ScreenModeRequest,
  85.         /*
  86.         ** initial conditions
  87.         */
  88.         ASLSM_InitialDisplayID,     *modeID,
  89.         ASLSM_InitialDisplayWidth,  DEFAULT_WIDTH,
  90.         ASLSM_InitialDisplayHeight, DEFAULT_HEIGHT,
  91.         ASLSM_InitialOverscanType , NULL,
  92.         ASLSM_InitialDisplayWidth,  MAX_DEPTH,
  93.         /*
  94.         ** setup stuff
  95.         */
  96.         ASLSM_SleepWindow,  TRUE,
  97.         ASLSM_TitleText,    "POVRay Render Screen",
  98.         ASLSM_MinWidth,     MINIMUM_WIDTH,
  99.         ASLSM_MinHeight,    MINIMUM_HEIGHT,
  100.         ASLSM_MinDepth,     MIN_DEPTH,
  101.         ASLSM_MaxDepth,        MAX_DEPTH,
  102.         ASLSM_PropertyFlags, pfl,
  103.         ASLSM_FilterFunc,   &ScreenReqHook,
  104.         /*
  105.         ** what can the user specify
  106.         */
  107.         ASLSM_DoWidth,        TRUE,
  108.         ASLSM_DoHeight,     TRUE,
  109.         ASLSM_DoAutoScroll, TRUE,
  110.         ASLSM_DoDepth,        DD,
  111.         TAG_DONE);
  112.  
  113.     if (!screenReq) 
  114.     {
  115.         fprintf(stderr,"Error: Failed to allocate ScreenModeRequester!\n");
  116.         exit(20);
  117.     }
  118.  
  119.     if (AslRequest (screenReq, NULL) == FALSE) 
  120.     {
  121.         fprintf(stderr,"Error: Failed to open Asl Screenmode Requester!\n");
  122.         rslt = 0;
  123.     }
  124.     else 
  125.     {
  126.         *modeID = screenReq->sm_DisplayID;
  127.         *height = screenReq->sm_DisplayHeight;
  128.         *width    = screenReq->sm_DisplayWidth;
  129.         *depth  = screenReq->sm_DisplayDepth;
  130.         *autoscroll = screenReq->sm_AutoScroll;
  131.         rslt = 1;
  132.     }
  133.  
  134.     FreeAslRequest (screenReq);
  135.  
  136.     return rslt;
  137. }
  138.